# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=networkx
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
         "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=1.11
pkgrel=2
pkgdesc="High-productivity software for complex networks (mingw-w64)"
arch=('any')
license=('BSD')
url="https://github.com/matplotlib/networkx"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-nose"
              "${MINGW_PACKAGE_PREFIX}-python2-nose")
source=("https://github.com/networkx/networkx/archive/${_realname}-${pkgver}.tar.gz")
sha256sums=('5d630c369f6d77591f32d7d15d882ed5c9299f8ea084e6f0f6afea8b63b0f5ce')

prepare() {
  cp -a networkx-${_realname}-${pkgver}{,-py2}
}

build() {
  cd ${srcdir}/networkx-${_realname}-${pkgver}
  python3 setup.py build

  cd ${srcdir}/networkx-${_realname}-${pkgver}-py2
  python2 setup.py build
}

check() {
  cd ${srcdir}/networkx-${_realname}-${pkgver}
  nosetests-3.5

  cd ${srcdir}/networkx-${_realname}-${pkgver}-py2
  nosetests-2.7
}

package_python3-networkx() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python3"
    "${MINGW_PACKAGE_PREFIX}-python3-decorator"
  )
  optdepends=(
    "${MINGW_PACKAGE_PREFIX}-python3-numpy"
    "${MINGW_PACKAGE_PREFIX}-python3-scipy"
    "${MINGW_PACKAGE_PREFIX}-python3-pyparsing"
    "${MINGW_PACKAGE_PREFIX}-python3-yaml"
  )

  cd networkx-${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -D -m644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
}

package_python2-networkx() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python2"
    "${MINGW_PACKAGE_PREFIX}-python2-decorator"
  )
  optdepends=(
    "${MINGW_PACKAGE_PREFIX}-python2-numpy"
    "${MINGW_PACKAGE_PREFIX}-python2-scipy"
    "${MINGW_PACKAGE_PREFIX}-python2-pyparsing"
    "${MINGW_PACKAGE_PREFIX}-python2-yaml"
)

  cd networkx-${_realname}-${pkgver}-py2
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -D -m644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
  
  # Conflict files for both packages.
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/doc
}

package_mingw-w64-i686-python2-networkx() {
  package_python2-networkx
}

package_mingw-w64-i686-python3-networkx() {
  package_python3-networkx
}

package_mingw-w64-x86_64-python2-networkx() {
  package_python2-networkx
}

package_mingw-w64-x86_64-python3-networkx() {
  package_python3-networkx
}

# vim:set ts=2 sw=2 et:
